<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>Hui</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="Hui">
<meta property="og:url" content="http://mhuihui.oschina.io/m-pages/index.html">
<meta property="og:site_name" content="Hui">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Hui">
  
    <link rel="alternate" href="/atom.xml" title="Hui" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/m-pages/css/style.css">
  

</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/m-pages/" id="logo">Hui</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/m-pages/">Home</a>
        
          <a class="main-nav-link" href="/m-pages/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://mhuihui.oschina.io/m-pages"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-go语言学习笔记（四)" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/m-pages/2017/02/10/go语言学习笔记（四)/" class="article-date">
  <time datetime="2017-02-10T04:06:53.246Z" itemprop="datePublished">2017-02-10</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/m-pages/2017/02/10/go语言学习笔记（四)/">go语言学习笔记（四）</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<figure class="highlight go"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> main</div><div class="line"></div><div class="line"><span class="keyword">import</span> (</div><div class="line">	<span class="string">"fmt"</span></div><div class="line">	<span class="string">"strings"</span></div><div class="line">)</div><div class="line"></div><div class="line"><span class="keyword">const</span> (</div><div class="line">	SPACE = <span class="string">" "</span></div><div class="line">	EMPTY = <span class="string">""</span></div><div class="line">	LF = <span class="string">"\n"</span></div><div class="line">	INDEX_NOT_FOUND = <span class="number">-1</span></div><div class="line">)</div><div class="line"></div><div class="line"><span class="comment">/**</span></div><div class="line"> * 判断字符串是否空</div><div class="line"> */</div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">IsEmpty</span><span class="params">(str <span class="keyword">string</span>)</span> <span class="title">bool</span></span> &#123;</div><div class="line">	<span class="keyword">if</span> <span class="built_in">len</span>(str) == <span class="number">0</span> &#123;</div><div class="line">		<span class="keyword">return</span> <span class="literal">true</span></div><div class="line">	&#125; <span class="keyword">else</span> &#123;</div><div class="line">		<span class="keyword">return</span> <span class="literal">false</span></div><div class="line">	&#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">IsBlack</span><span class="params">(str <span class="keyword">string</span>)</span> <span class="title">bool</span></span> &#123;</div><div class="line">	isEmpty := IsEmpty(str)</div><div class="line">	<span class="keyword">if</span> isEmpty &#123;</div><div class="line">		<span class="keyword">return</span> isEmpty</div><div class="line">	&#125; <span class="keyword">else</span> &#123;</div><div class="line">		<span class="keyword">if</span> IsEmpty(Trim(str)) &#123;</div><div class="line">			<span class="keyword">return</span> <span class="literal">true</span></div><div class="line">		&#125; <span class="keyword">else</span> &#123;</div><div class="line">			<span class="keyword">return</span> <span class="literal">false</span></div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">IsNotBlack</span><span class="params">(str <span class="keyword">string</span>)</span> <span class="title">bool</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> !IsBlack(str)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="comment">/**</span></div><div class="line"> * 判断字符串是否非空</div><div class="line"> */</div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">IsNotEmpty</span><span class="params">(str <span class="keyword">string</span>)</span> <span class="title">bool</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> !IsEmpty(str)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">Trim</span><span class="params">(str <span class="keyword">string</span>)</span> <span class="title">string</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> strings.TrimSpace(str)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">SubString</span><span class="params">(str <span class="keyword">string</span>, begin, length <span class="keyword">int</span>)</span> <span class="title">string</span></span> &#123;</div><div class="line">	<span class="comment">// 将字符串的转换成</span></div><div class="line">	rs := []<span class="keyword">rune</span>(str)</div><div class="line">	lth := <span class="built_in">len</span>(rs)</div><div class="line">	<span class="comment">// 简单的越界判断</span></div><div class="line">	<span class="keyword">if</span> begin &lt; <span class="number">0</span> &#123;</div><div class="line">		begin = <span class="number">0</span></div><div class="line">	&#125;</div><div class="line">	<span class="keyword">if</span> begin &gt;= lth &#123;</div><div class="line">		begin = lth</div><div class="line">	&#125;</div><div class="line">	end := begin + length</div><div class="line">	<span class="keyword">if</span> end &gt; lth &#123;</div><div class="line">		end = lth</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">return</span> <span class="keyword">string</span>(rs[begin:end])</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">SubString1</span><span class="params">(str <span class="keyword">string</span>, length <span class="keyword">int</span>)</span> <span class="title">string</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> SubString(str, <span class="number">0</span>, length)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">UpCase</span><span class="params">(str <span class="keyword">string</span>)</span> <span class="title">string</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> strings.ToUpper(str)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">LowerCase</span><span class="params">(str <span class="keyword">string</span>)</span> <span class="title">string</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> strings.ToLower(str)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">Equal</span><span class="params">(str1, str2 <span class="keyword">string</span>)</span> <span class="title">bool</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> str1 == str2</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">EqualIgnoreBlack</span><span class="params">(str1, str2 <span class="keyword">string</span>)</span> <span class="title">bool</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> Trim(str1) == Trim(str2)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">IndexOf</span><span class="params">(str <span class="keyword">string</span>, sep <span class="keyword">string</span>)</span> <span class="title">int</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> strings.Index(str, sep)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">Contains</span><span class="params">(str, sep <span class="keyword">string</span>)</span> <span class="title">bool</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> strings.Contains(str, sep)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="comment">//TODO</span></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">ToString</span><span class="params">(obj <span class="keyword">interface</span>&#123;&#125;)</span> <span class="title">string</span></span> &#123;</div><div class="line">	<span class="keyword">switch</span> obj.(<span class="keyword">type</span>) &#123;</div><div class="line">	<span class="keyword">case</span> <span class="keyword">int</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">int8</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">int16</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">int32</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">int64</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">uint</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">uintptr</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">uint8</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">uint16</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">uint32</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">uint64</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">float32</span>:</div><div class="line">	<span class="keyword">case</span> <span class="keyword">float64</span>:</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">return</span> <span class="string">""</span></div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</div><div class="line"></div><div class="line">	str1 := <span class="string">""</span></div><div class="line">	isEmpty := IsNotEmpty(str1)</div><div class="line">	fmt.Println(isEmpty)</div><div class="line"></div><div class="line">	str2 := <span class="string">"   "</span></div><div class="line">	isBlack := IsBlack(str2)</div><div class="line">	fmt.Println(isBlack)</div><div class="line"></div><div class="line">	str3 := <span class="string">"  1 "</span></div><div class="line">	reults1 := Trim(str3)</div><div class="line">	fmt.Println(reults1)</div><div class="line"></div><div class="line">	str4 := <span class="string">"1234567890"</span></div><div class="line">	reults2 := SubString(str4, <span class="number">1</span>, <span class="number">6</span>)</div><div class="line">	fmt.Println(reults2)</div><div class="line"></div><div class="line">	fmt.Println(Equal(str1, str2))</div><div class="line">	fmt.Println(EqualIgnoreBlack(str1, str2))</div><div class="line">&#125;</div></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://mhuihui.oschina.io/m-pages/m-pages/2017/02/10/go语言学习笔记（四)/" data-id="ciyzazask000zs8vghyirxgs3" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/m-pages/tags/编程/">编程</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-hello-world" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/m-pages/2017/02/10/hello-world/" class="article-date">
  <time datetime="2017-02-10T02:06:26.135Z" itemprop="datePublished">2017-02-10</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/m-pages/2017/02/10/hello-world/">Hello World</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>Welcome to <a href="https://hexo.io/" target="_blank" rel="external">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/" target="_blank" rel="external">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html" target="_blank" rel="external">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="external">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo new <span class="string">"My New Post"</span></div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="external">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo server</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="external">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo generate</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="external">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo deploy</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/deployment.html" target="_blank" rel="external">Deployment</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://mhuihui.oschina.io/m-pages/m-pages/2017/02/10/hello-world/" data-id="ciyzazasl0011s8vgkg0yoz3j" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-go语言学习笔记（三）" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/m-pages/2017/01/14/go语言学习笔记（三）/" class="article-date">
  <time datetime="2017-01-14T11:41:38.000Z" itemprop="datePublished">2017-01-14</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/m-pages/2017/01/14/go语言学习笔记（三）/">go语言学习笔记（三）</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<figure class="highlight go"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> main</div><div class="line"></div><div class="line"><span class="keyword">import</span> (</div><div class="line">	<span class="string">"fmt"</span></div><div class="line">)</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</div><div class="line">	<span class="comment">/*增强for 循环*/</span></div><div class="line">	rangeDemo1()</div><div class="line">	<span class="comment">/*map 的使用*/</span></div><div class="line">	mapDemo()</div><div class="line">	<span class="comment">/*递归实现1+ ... +10*/</span></div><div class="line">	sum := digui(<span class="number">0</span>,</div><div class="line">		<span class="number">0</span>)</div><div class="line">	fmt.Println(sum)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">mapDemo</span><span class="params">()</span></span> &#123;</div><div class="line">	<span class="comment">//map[string]string	key(String) value(String)</span></div><div class="line">	<span class="comment">/*创建集合*/</span></div><div class="line">	<span class="keyword">var</span> mapParam <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">string</span> = <span class="built_in">make</span>(<span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">string</span>)</div><div class="line">	mapParam[<span class="string">"France"</span>] = <span class="string">"Paris"</span></div><div class="line">	mapParam[<span class="string">"Italy"</span>] = <span class="string">"Rome"</span></div><div class="line">	mapParam[<span class="string">"Japan"</span>] = <span class="string">"Tokyo"</span></div><div class="line">	mapParam[<span class="string">"India"</span>] = <span class="string">"New Delhi"</span></div><div class="line">	fmt.Println(mapParam)</div><div class="line"></div><div class="line">	<span class="keyword">for</span> temp := <span class="keyword">range</span> mapParam &#123;</div><div class="line">		fmt.Println(temp, mapParam[temp])</div><div class="line">	&#125;</div><div class="line">	isExits := mapParam[<span class="string">"France"</span>]</div><div class="line">	fmt.Println(isExits)</div><div class="line">	<span class="comment">//集合元素移除，这个方法不好有歧义</span></div><div class="line">	<span class="built_in">delete</span>(mapParam, <span class="string">"France"</span>)</div><div class="line">	fmt.Println(mapParam)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">rangeDemo1</span><span class="params">()</span></span> &#123;</div><div class="line">	<span class="keyword">var</span> arr = []<span class="keyword">int</span>&#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>&#125;</div><div class="line">	sum := <span class="number">0</span></div><div class="line">	<span class="comment">// 类似与增强for循环</span></div><div class="line">	<span class="keyword">for</span> _, num := <span class="keyword">range</span> arr &#123;</div><div class="line">		sum += num</div><div class="line">	&#125;</div><div class="line">	fmt.Println(sum)</div><div class="line">	fmt.Println(arr)</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line">如何通过递归实现1+ ... + 10</div><div class="line">*/</div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">digui</span><span class="params">(n, sum <span class="keyword">int</span>)</span> <span class="title">int</span></span> &#123;</div><div class="line">	<span class="keyword">if</span> n &gt; <span class="number">100</span> &#123;</div><div class="line">		<span class="keyword">return</span> sum</div><div class="line">	&#125; <span class="keyword">else</span> &#123;</div><div class="line">		<span class="keyword">return</span> digui(n+<span class="number">1</span>, sum+n)</div><div class="line">	&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://mhuihui.oschina.io/m-pages/m-pages/2017/01/14/go语言学习笔记（三）/" data-id="ciyzazasg000vs8vg9wlnpe45" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/m-pages/tags/编程/">编程</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-go语言学习笔记（二）" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/m-pages/2017/01/13/go语言学习笔记（二）/" class="article-date">
  <time datetime="2017-01-13T15:41:38.000Z" itemprop="datePublished">2017-01-13</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/m-pages/2017/01/13/go语言学习笔记（二）/">go语言学习笔记（二）结构体和切片</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<figure class="highlight go"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> main</div><div class="line"></div><div class="line"><span class="keyword">import</span> (</div><div class="line">	<span class="string">"fmt"</span></div><div class="line">)</div><div class="line"></div><div class="line"><span class="keyword">type</span> Book <span class="keyword">struct</span> &#123;</div><div class="line">	name   <span class="keyword">string</span></div><div class="line">	value  <span class="keyword">int</span></div><div class="line">	author <span class="keyword">string</span></div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</div><div class="line">	structDemo()</div><div class="line">	slice1()</div><div class="line">	slice2()</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">structDemo</span><span class="params">()</span></span> &#123;</div><div class="line">	<span class="keyword">var</span> book1 Book</div><div class="line">	book1.author = <span class="string">"杨慧强"</span></div><div class="line">	book1.name = <span class="string">"java"</span></div><div class="line">	book1.value = <span class="number">12</span></div><div class="line">	fmt.Println(book1)</div><div class="line"></div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">slice1</span><span class="params">()</span></span> &#123;</div><div class="line">	<span class="comment">// 切片有遗留问题</span></div><div class="line">	numbers := <span class="built_in">make</span>([]<span class="keyword">int</span>, <span class="number">3</span>, <span class="number">5</span>)</div><div class="line">	<span class="comment">// 这个是空切片</span></div><div class="line">	<span class="keyword">var</span> numbers1 []<span class="keyword">int</span></div><div class="line">	fmt.Println(numbers)</div><div class="line">	<span class="keyword">if</span> numbers == <span class="literal">nil</span> || numbers1 == <span class="literal">nil</span> &#123;</div><div class="line">		fmt.Println(<span class="string">"null"</span>)</div><div class="line">	&#125;</div><div class="line">	printSlice(numbers)</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">printSlice</span><span class="params">(numbers []<span class="keyword">int</span>)</span></span> &#123;</div><div class="line">	fmt.Printf(<span class="string">"len=%d cap=%d"</span>, <span class="built_in">len</span>(numbers), <span class="built_in">cap</span>(numbers))</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">slice2</span><span class="params">()</span></span> &#123;</div><div class="line">	<span class="comment">/* 创建切片 */</span></div><div class="line">	numbers := []<span class="keyword">int</span>&#123;<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>&#125;</div><div class="line">	printSlice(numbers)</div><div class="line"></div><div class="line">	<span class="comment">/* 打印原始切片 */</span></div><div class="line">	fmt.Println(<span class="string">"numbers =="</span>, numbers)</div><div class="line"></div><div class="line">	<span class="comment">/* 打印子切片从索引1(包含) 到索引4(不包含)*/</span></div><div class="line">	fmt.Println(<span class="string">"numbers[1:4] =="</span>, numbers[<span class="number">1</span>:<span class="number">4</span>])</div><div class="line"></div><div class="line">	<span class="comment">/* 默认下限为 0*/</span></div><div class="line">	fmt.Println(<span class="string">"numbers[:3] =="</span>, numbers[:<span class="number">3</span>])</div><div class="line"></div><div class="line">	<span class="comment">/* 默认上限为 len(s)*/</span></div><div class="line">	fmt.Println(<span class="string">"numbers[4:] =="</span>, numbers[<span class="number">4</span>:])</div><div class="line"></div><div class="line">	numbers1 := <span class="built_in">make</span>([]<span class="keyword">int</span>, <span class="number">0</span>, <span class="number">5</span>)</div><div class="line">	printSlice(numbers1)</div><div class="line"></div><div class="line">	<span class="comment">/* 打印子切片从索引  0(包含) 到索引 2(不包含) */</span></div><div class="line">	number := numbers[:<span class="number">2</span>]</div><div class="line">	printSlice(number)</div><div class="line"></div><div class="line">	<span class="comment">/* 打印子切片从索引 2(包含) 到索引 5(不包含) */</span></div><div class="line">	number3 := numbers[<span class="number">2</span>:<span class="number">5</span>]</div><div class="line">	printSlice(number3)</div><div class="line">&#125;</div></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://mhuihui.oschina.io/m-pages/m-pages/2017/01/13/go语言学习笔记（二）/" data-id="ciyzazasi000xs8vgpucy6hdv" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/m-pages/tags/编程/">编程</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-go语言学习笔记（一）" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/m-pages/2017/01/12/go语言学习笔记（一）/" class="article-date">
  <time datetime="2017-01-12T14:11:38.000Z" itemprop="datePublished">2017-01-12</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/m-pages/2017/01/12/go语言学习笔记（一）/">go语言开发环境搭建</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<h2 id="go-语言环境的搭建及其语言本身介绍"><a href="#go-语言环境的搭建及其语言本身介绍" class="headerlink" title="go 语言环境的搭建及其语言本身介绍"></a>go 语言环境的搭建及其语言本身介绍</h2><h3 id="go-介绍"><a href="#go-介绍" class="headerlink" title="go 介绍"></a>go 介绍</h3><ul>
<li>为什么要学习这门语言？<ul>
<li>一个程序员应该掌握３门以上比较熟练的开发语言，你掌握了几门？你是不是有必要再去学习一门新的语言了？学习新的语言会不会对你已经熟悉的语言有所启发了？</li>
<li>上面的问题答案都是肯定的。为什么要学习这门语言了？因为他有着：快速编译，高效执行，易于开发; 执行速度快于java学习成本低于C、Ｃ++ 为什么不学习他了？</li>
<li>学习一门要看他的发展怎么样，go 背靠Google所以绝对是可靠的。</li>
</ul>
</li>
</ul>
<h3 id="开发环境搭建"><a href="#开发环境搭建" class="headerlink" title="开发环境搭建"></a>开发环境搭建</h3><blockquote>
<p>开发系统Ubuntu 14</p>
<p>Ubuntu 下直接通过软件中心安装，具体流程如下</p>
</blockquote>
<p>sudo apt -get update    更新软件源<br>sudo apt -get install golang    开始安装<br>安装完成后，验证是否安装成功<br>go version    查看版本<br>go version go1.7.4 linux/amd64<br>go env    查看环境<br>如果上面两条命令有正常输出,安装成功</p>
<blockquote>
<p>通过官网下载最新安装包安装<br> <a href="https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz" target="_blank" rel="external">下载链接</a><br> 通过命令：<code>axel -n 10  https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz</code> 下载速度更加快</p>
<p>下载完成解压 </p>
</blockquote>
<p>sudo tar -C /opt/ -zxf /go1.7.4.linux-amd64.tar.gz</p>
<blockquote>
<p>配置环境变量</p>
</blockquote>
<p>sudo vim /etc/profile<br>添加<br>GOROOT = /opt/go<br>$PATH= $PATH:$GOPATH/bin<br>source /etc/profile</p>
<blockquote>
<p>验证安装</p>
</blockquote>
<p>go env</p>
<h3 id="开始你的第一个程序"><a href="#开始你的第一个程序" class="headerlink" title="开始你的第一个程序"></a>开始你的第一个程序</h3><blockquote>
<p>环境搭建完成怎么写出一个helloworld 了？</p>
</blockquote>
<p>go</p>
<p>touch demo.go<br>vim demo.go</p>
<p>开始写啦<br>package main</p>
<p>import “fmt”</p>
<p>func main() {<br>    fmt.Println(“你好世界”)<br>}</p>
<p>完成：run一下<br>go run demo.go</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://mhuihui.oschina.io/m-pages/m-pages/2017/01/12/go语言学习笔记（一）/" data-id="ciyzazasa000qs8vg9mahul9s" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/m-pages/tags/编程/">编程</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-golang环境搭建" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/m-pages/2017/01/12/golang环境搭建/" class="article-date">
  <time datetime="2017-01-12T12:11:38.000Z" itemprop="datePublished">2017-01-12</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/m-pages/2017/01/12/golang环境搭建/">go语言学习笔记（一）</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<figure class="highlight go"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> main</div><div class="line"></div><div class="line"><span class="keyword">import</span> (</div><div class="line">	<span class="string">"fmt"</span></div><div class="line">	<span class="string">"unsafe"</span></div><div class="line">)</div><div class="line"></div><div class="line"><span class="keyword">var</span> a <span class="keyword">string</span> = <span class="string">"12"</span></div><div class="line"><span class="keyword">var</span> b = <span class="number">12</span></div><div class="line"><span class="keyword">var</span> c <span class="keyword">int</span></div><div class="line"><span class="keyword">var</span> (</div><div class="line">	str1      = <span class="string">"123456789"</span></div><div class="line">	name1 <span class="keyword">int</span> = <span class="built_in">len</span>(str1)</div><div class="line">	name2     = unsafe.Sizeof(str1)</div><div class="line">)</div><div class="line"></div><div class="line"><span class="keyword">const</span> PI = <span class="number">3</span></div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</div><div class="line">	<span class="comment">// 你好世界</span></div><div class="line">	<span class="comment">/*你好世界*/</span></div><div class="line">	fmt.Println(<span class="string">"你好;世界"</span>)</div><div class="line">	c = <span class="number">100</span></div><div class="line">	fmt.Printf(a, b, c)</div><div class="line">	fmt.Println(name1)</div><div class="line">	fmt.Println(name2)</div><div class="line">	<span class="keyword">var</span> o = PI * c</div><div class="line">	fmt.Println(o)</div><div class="line"></div><div class="line">	<span class="keyword">const</span> (</div><div class="line">		a = <span class="literal">iota</span> <span class="comment">//0</span></div><div class="line">		b        <span class="comment">//1</span></div><div class="line">		c        <span class="comment">//2</span></div><div class="line">		d = <span class="string">"ha"</span> <span class="comment">//独立值，iota += 1</span></div><div class="line">		e        <span class="comment">//"ha"   iota += 1</span></div><div class="line">		f = <span class="number">100</span>  <span class="comment">//iota +=1</span></div><div class="line">		g        <span class="comment">//100  iota +=1</span></div><div class="line">		h = <span class="literal">iota</span> <span class="comment">//7,恢复计数</span></div><div class="line">		i        <span class="comment">//8</span></div><div class="line">	)</div><div class="line">	fmt.Println(<span class="string">"start"</span>, a, b, c, d, e, f, g, h, i)</div><div class="line"></div><div class="line">	<span class="keyword">var</span> demo1 <span class="keyword">bool</span> = <span class="literal">true</span></div><div class="line">	<span class="keyword">var</span> demo2 = <span class="literal">false</span></div><div class="line"></div><div class="line">	<span class="keyword">if</span> demo1 &amp;&amp; !demo2 &#123;</div><div class="line">		fmt.Println(<span class="string">"TRUE"</span>)</div><div class="line">	&#125; <span class="keyword">else</span> &#123;</div><div class="line">		fmt.Println(<span class="string">"中国"</span>)</div><div class="line">	&#125;</div><div class="line"></div><div class="line">	<span class="keyword">var</span> ptr *<span class="keyword">int</span></div><div class="line">	ptr = &amp;o</div><div class="line">	fmt.Println(ptr)</div><div class="line">	fmt.Println(*ptr)</div><div class="line">	<span class="keyword">var</span> c1, c2, c3 <span class="keyword">chan</span> <span class="keyword">int</span></div><div class="line">	<span class="keyword">var</span> i1, i2 <span class="keyword">int</span></div><div class="line">	<span class="keyword">select</span> &#123;</div><div class="line">	<span class="keyword">case</span> i1 = &lt;-c1:</div><div class="line">		fmt.Printf(<span class="string">"received "</span>, i1, <span class="string">" from c1\n"</span>)</div><div class="line">	<span class="keyword">case</span> c2 &lt;- i2:</div><div class="line">		fmt.Printf(<span class="string">"sent "</span>, i2, <span class="string">" to c2\n"</span>)</div><div class="line">	<span class="keyword">case</span> i3, ok := (&lt;-c3): <span class="comment">// same as: i3, ok := &lt;-c3</span></div><div class="line">		<span class="keyword">if</span> ok &#123;</div><div class="line">			fmt.Printf(<span class="string">"received "</span>, i3, <span class="string">" from c3\n"</span>)</div><div class="line">		&#125; <span class="keyword">else</span> &#123;</div><div class="line">			fmt.Printf(<span class="string">"c3 is closed\n"</span>)</div><div class="line">		&#125;</div><div class="line">	<span class="keyword">default</span>:</div><div class="line">		fmt.Printf(<span class="string">"no communication\n"</span>)</div><div class="line">	&#125;</div><div class="line"></div><div class="line">	fmt.Println(max(<span class="number">1</span>, <span class="number">2</span>))</div><div class="line">	<span class="keyword">var</span> x, y = swap(<span class="string">"str1"</span>, <span class="string">"str2"</span>)</div><div class="line">	fmt.Println(x, y)</div><div class="line"></div><div class="line">	array()</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">max</span><span class="params">(num1, num2 <span class="keyword">int</span>)</span> <span class="title">int</span></span> &#123;</div><div class="line">	<span class="keyword">if</span> num1 &gt; num2 &#123;</div><div class="line">		<span class="keyword">return</span> <span class="number">1</span></div><div class="line">	&#125; <span class="keyword">else</span> <span class="keyword">if</span> num1 &lt; num2 &#123;</div><div class="line">		<span class="keyword">return</span> <span class="number">-1</span></div><div class="line">	&#125; <span class="keyword">else</span> &#123;</div><div class="line">		<span class="keyword">return</span> <span class="number">0</span></div><div class="line">	&#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">swap</span><span class="params">(str1, str2 <span class="keyword">string</span>)</span> <span class="params">(<span class="keyword">string</span>, <span class="keyword">string</span>)</span></span> &#123;</div><div class="line">	<span class="keyword">return</span> str2, str1</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">func</span> <span class="title">array</span><span class="params">()</span></span> &#123;</div><div class="line">	<span class="keyword">var</span> var_array = []<span class="keyword">int</span>&#123;<span class="number">1</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">6</span>, <span class="number">7</span>&#125;</div><div class="line">	fmt.Println(var_array)</div><div class="line"></div><div class="line">	<span class="keyword">for</span> i := <span class="number">0</span>; i &lt; <span class="built_in">len</span>(var_array); i++ &#123;</div><div class="line">		fmt.Printf(<span class="string">"var_array[%d] = %d \n"</span>, i, var_array[i])</div><div class="line">	&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      <a data-url="http://mhuihui.oschina.io/m-pages/m-pages/2017/01/12/golang环境搭建/" data-id="ciyzazase000ss8vgviwp242s" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/m-pages/tags/编程/">编程</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-Struts总结" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/m-pages/2017/01/11/Struts总结/" class="article-date">
  <time datetime="2017-01-11T04:15:38.000Z" itemprop="datePublished">2017-01-11</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/m-pages/2017/01/11/Struts总结/">Struts总结</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<p>一、struts的作用<br>二、struts的MVC<br>m(model):<br>facade<br>dao<br>v(view):<br>jsp<br>ActionForm:承载页面的信息，页面表单域的名称与form的属性必须相等<br>c(control):<br>ActionServlet:接收所有的请求<br>RequestProcessor:是ActionServlet的一个助手，做详细的处理<br>ActionMapping:对应一个action标记，包括url、action、form、actionForward</p>
<p><action path="\login" type="struts.action.InsertAction" name="userForm" scope="request"></action></p>
<p><forward name="success" path="/success.jsp"></forward></p>
<p><forward name="error" path="/error.jsp"><br><br>Action:做具体的业务处理<br>ActionForward:转发到另一个页面<br>三、struts的请求处理过程<br>1、通过url.do在struts-config.xml中找到对应的action及actionForm<br>2、如果有actionForm用已有的，没有产生一新的，通过返射将表单域的值注<br>入到actionForm实例中。<br>3、如果有action用已有的，没有产生一个新的，调用action的execute方法，<br>在调用之前将actionForm注入到execute方法中。<br>4、execute在执行结束前通过actionMapping找到一个ActionForward，转发到下一个页面。</forward></p>
<p>struts与dao hibernate整合简要说明&lt;具体祥见框架&gt;<br>将IFcade作为BaseAction的一个属性，通过FacadeFactory产Facade实例，返回一个IFacade接口。<br>facade<br>IFacade<br>Facade<br>FacadeFactory:<br>产Facade实例，返回一个IFacade接口。<br>dao<br>UserDao接口<br>UserDao实现类<br>UserDaoFactory：产生具体的UserDao实现类，返回一个抽象的接口<br>AbstractFactory:用了单例、返射、工厂，实例化了UserDaoFactory,<br>返回了一个AbstractFactory抽象类。因为UserDaoFactory<br>是AbstractFacatory的子类，所以业务层调用的还是子类的<br>getUserDao方法产生具体的UserDao实现实例，返回UserDao接口。<br>hibernate:持久化</p>
<p>第一章、struts简介<br>一、struts中的MVC<br>M:<br>业务、持久<br>V:<br>jsp<br>ActionForm<br>C:<br>ActionServlet<br>RequestProcessor<br>ActionMapping<br>Action<br>ActionForward<br>作用:使业务层与界面层强制解藕<br>二、处理过程:<br>*.do请求表ActionServlet<br>ActionServlet转发到RequestProcessor<br>RequestProcessor根据url在struts-config.xml中找到ActionForm Action<br>RequestProcessor实例化ActionForm并根据类的返射填充ActionForm<br>RequestProcessor实例化Action并调用Action的execute方法。<br>execute方法执行完后返回一个ActionForward转发到另一个jsp页面。<br>三、struts的特点<br>struts中的Action中一个单例模式(singlton)<br>struts只关心web层的处理，对于业务层及持久层不管。<br>四、model2的体系结构<br>MVC<br>M:javaBean<br>V:jsp<br>C:servlet<br>第二章、控制器组件<br>一、struts中的MVC<br>M:<br>业务、持久<br>V:<br>jsp<br>ActionForm<br>C:<br>ActionServlet<br>RequestProcessor<br>ActionMapping<br>Action<br>ActionForward<br>作用:使业务层与界面层强制解藕<br>二、RequestProcessor的处理过程<br>processPath() 确定选择将要处理的动作的路径<br>processMapping() 为请求选择动作映射</p>
<p><action path="/login" type="struts.action.LoginAction" name="userForm" attribute="userForm" scope="session" input="/login.jsp" validate="true"></action></p>
<p><forward name="success" path="/succ.jsp"></forward></p>
<p><forward name="error" path="/error.jsp"><br><br>processActionForm() 新建一个 Form Bean 或从请求会话中检索 Form Bean<br>processPopulate() 填充与请求关联的 ActionForm<br>processForward() 处理 <action-mapping> 元素的 forward 以匹配当前的请求路径<br>processValidate() 调用 Form Bean 的 validate() 方法<br>processActionCreate() 实例化当前 ActionMapping 指定的类的实例<br>processActionPerform() 将调用 action 的 perform() 或 execute() 方法 processPreprocess() 告诉请求处理器调用此方法后是否应继续处理请求<br>三、数据源连接<br><data-sources><br><data-source key="Sql" type="org.apache.commons.dbcp.BasicDataSource"></data-source></data-sources></action-mapping></forward></p>
<p><set-property property="driverClassName" value="sun.jdbc.odbc.JdbcOdbcDriver"></set-property></p>
<p><set-property property="url" value="jdbc:odbc:accp"></set-property></p>
<p><set-property property="username" value=""></set-property></p>
<p><set-property property="password" value=""><br><br><br>取:<br>ServletContext context = servlet.getServletContext();<br>DataSource dataSource = (DataSource) context.getAttribute(“Sql”);<br>Conneciton con=dataSource.getConnection();<br>第三章、视图组件<br>struts的标签库</set-property></p>
<p><html:select property=""></html:select></p>
<p><html:options collection="集合" property="真实值" labelproperty="显示值"><br></html:options></p>
<p><option value="01">男</option><br>html:因为form的对象可以放到request或session中，当转发到的页面通过html标记直接显示<br>form中的值。<br>1、html:text/html:password<br>2、html:select如果下拉列表的值与集合中的值一样会自动选中</p>
<p><html:select property="sex"></html:select></p>
<p><html:options collections="sexes" property="" labelproperty=""><br>//sexes是在session或request或application中对象<br></html:options></p>
<p><html></html></p>
<p><html:select property=""></html:select></p>
<p><html:options><br></html:options></p>
<p><html:radio></html:radio></p>
<p><html:mulitibox value="" property="字符串数组"><br>1、错误返回的页面可以保留以前的值。<br>2、转发后的form名及范围与前一个form相同，可以直接显示</html:mulitibox></p>
<p><bean></bean></p>
<p><bean:define name="" id="" scope=""><br>从scope中取出name放到变量id中。</bean:define></p>
<p><bean:define id="" scope="" name="" property="属性名"><br>从scope中取出name的property属性放到变量id中。</bean:define></p>
<p><bean:write name="" property=""><br>将对象name的值打印。</bean:write></p>
<p><bean:message key=""><br>通过键名取国际化的值</bean:message></p>
<p><logic></logic></p>
<p><logic:iterator id="" scope="" name=""><br>从scope中取出集合name将其每一个元素放到id中。</logic:iterator></p>
<p><logic:iterator id="" scope="" name="" property=""><br>从scope中取出对象name的property属性值(集合),将其每一个元素放到id中。</logic:iterator></p>
<p><logic:present name="" scope=""><br>在scope中是否存在name对象<br>struts的国际化:不用修改源代码只加入一个properties文件实现国际化<br>一、资源文件:名称<em>语言</em>国家.properties<br>message_en_US.properties<br>message_zh_CN.properties<br>如果有非英语或数字，需将资源文件转码native2ascii -encoding utf-8 源 目<br>二、在struts-config.xml指定资源文件的名称:包名+文件名(struts.message)<br>三、在jsp中通<bean:message key="">通过键名加载相关的消息。<br>struts的校验框架<br>手动:所有校验规则要写代码。<br>1、国际化两步曲<br>2、必须覆盖validate方法<br>public class MyForm extends ActionForm<br>{<br>public ActionErrors validate()<br>{<br>//如果ActionErrors.size()&gt;=1返回到input页面<br>errors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage(“userName”));<br>//new ActionMessage(“userName”)是键名，保证消息不为空<br>}<br>}<br>3、修改struts-config.xml文件，加入如下信息</bean:message></logic:present></p>
<p><action attribute="loginForm" input="/login.jsp" name="loginForm" path="/login" scope="request" type="struts.action.LoginAction" validate="true"><br>4、在jsp页面中通过messages标记显示</action></p>
<p><html:messages id="errors"></html:messages></p>
<p></p><p></p>
<p><bean:write name="errors"><br></bean:write></p><br><br>自动:不用写校验代码，通过xml文件说具体的校验规则<br>1、国际化两步曲<br>2、校验通用两步曲<br>a、jsp页面显示错误<br>b、修改action标签加入validate、input属性<br>3、继承于ValidateForm，因不能覆盖validate方法<br>public class MyForm extends ValidateForm<br>{<br>//public ActionErrors validate()<br>//{<br>// 如果ActionErrors.size()&gt;=返回到input页面<br>//}<br>}<br>3、通过配置文件加载两个xml文件<br>a、拷入validation-rules.xml，用的struts1.2的。<br>b、将validataion-rules.xml拷贝一份修改如下:<p></p>
<p><formset></formset></p>
<p><form name="loginForm"></form></p>
<p><field property="userName" depends="required"></field></p>
<p><arg0 key="userName"><br></arg0></p>
<p><field property="pwd" depends="required,minlength"></field></p>
<p><arg0 key="pwd"></arg0></p>
<p><arg1 resource="false" key="${var:minlength}"><br><var><br><var-name>minlength</var-name><br><var-value>6</var-value><br></var><br><br><br><br>c、通过插件加入以上的两个文件</arg1></p>
<p><plug-in classname="org.apache.struts.validator.ValidatorPlugIn"></plug-in></p>
<p><set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"><br></set-property></p>
<p>action的分类:<br>Action只有一个execute方法<br>DispatchAction:可以有多个方法<br>public 类 extends DispatchAction<br>{<br>public void add()<br>{}<br>}</p>
<p><action attribute="loginForm" input="/login.jsp" name="loginForm" path="/login" scope="request" validate="true" type="struts.action.LoginAction" parameter="表单域名"><br>tiles:可以定义jsp页面的布局<br>tiles的使用:将由多个页面组成的主页面整体布局，是通过<br>tiles的一个xml文件来说明，如果页面的结构或具体内容<br>发生了改变，只需修改tiles.xml文件，不用改具体的页面代码<br>如<jsp:include>。<br>–做一个action，其转发的结果tiles中的index</jsp:include></action></p>
<p>&lt;action path=”index” type=”struts.action.IndexAction”</p>
<p><forward name="success" path="index"><br><br>–通过tiles中的index转发到了main.jsp页面</forward></p>
<p><tiles-definitions></tiles-definitions></p>
<p><definition name="index" path="/main.jsp"></definition></p>
<p><put name="head" value="/head.jsp"></put></p>
<p><put name="foot" value="/foot.jsp"></put></p>
<p><put name="body" value="/body.jsp"><br><br><br>–main.jsp页面</put></p>
<p><tiles:insert attribute="head"></tiles:insert></p>
<p><tiles:insert attribute="body"></tiles:insert></p>
<tiles:insert attribute="foot">



<p>一、struts的MVC<br>M:model<br>V:view<br>jsp<br>ActionForm<br>C:control<br>ActionServlet:接收所有以.*结尾的请求<br>RequestProcessor:是ActionServlet的一个助手，做具体的处理。<br>ActionMapping:一个action标签，通过它可以找到Action、ActionForm<br>ActionForward。</p>
<p><action type="struts.action.LoginAction" name="loginForm" attribute="loginForm" 在request或session中的键名="" scope="request/session" input="/login.jsp" 在校验框架中有错误转发到input对应的页面="" validate="true" 告诉struts当前的form需要校验=""></action></p>
<p><forward name="success" path="/success.jsp"><br><br>Action:做具体的业务处理<br>ActionForward:转发一另一个页面。<br>二、struts的请求处理过程<br>1、通过url.do在struts-config.xml中找到对应的action及ActionForm<br>2、如果有ActionForm用已有的，没有产生一个新的实例，并通过返射将表<br>单域的值填充到ActionForm中。<br>3、如果有Action用已有的，没有产生一个新的，调用Action的execute方法<br>在调用execute方法之前通过参数将ActionForm注入到execute方法中。<br>4、execute方法执行结束前，通过ActionMapping找到一个ActionForward<br>转发到下一个jsp页面。<br>三、struts的标签库<br>html:前一个action转发下一个jsp页面，该jsp页面可以重用<br>上一个action所用的form,通过html标签可以直接显示form中的值。<br>FindAction:<br>public ActionForward execute()<br>{<br>UserForm uf=(UserForm)form;<br>mapping.findForward(“updateJsp”);<br>}<br>update.jsp页面:</forward></p>
<p><action path="/update" scope="request" name="userForm" attribute="userForm" type="struts.action.UpdateAction"></action></p>
<p><html:form action="/update"></html:form></p>
<p><html:text property="userName"><br></html:text></p>
<p><html:select property="sex"></html:select></p>
<p><html:collection collection="users" property="code" labelproperty="name"><br><br>bean:对已有bean的操作<br><!--从scope中取出user的userName属性打印--></html:collection></p>
<p><bean:write scope="request/application/session" name="user" property="userName"><br><!--从scope中取出customer对象，放作用域对象page中,键名还是customer1--></bean:write></p>
<p><bean:define scope="request/session/application" name="customer" id="customer1"><br><!--从scope中取出customer对象的buies属性，放作用域对象page中,键名还是buies--></bean:define></p>
<p><bean:define scope="request/session/application" name="customer" property="buies" id="buies"><br>logic:<br><!--如果在scope中有customer，执行标签内的代码--></bean:define></p>
<p><logic:present scope="request/session/appliation" name="customer"><br>执行部分<br></logic:present><br><!--如果在scope中没有customer，执行标签内的代码--></p>
<p><logic:notpresent scope="request/session/appliation" name="customer"><br></logic:notpresent><br><!--取集合中值--><br><!--从request中取出customer对象的buies属性遍历，每个元素通过buy引用--></p>
<p><logic:iterator scope="request" name="customer" property="buies" id="buy"><br></logic:iterator><br>tiles:</p>
<p><tiles:insert attribute="从页面在tiles-defs.xml中定义的名称"><br>四、struts的国际化<br>1、作用:不用改源代码，只需加入一个properties文件，就可以适应不同国家的语言。<br>2、实现步骤:<br>1、加入properties文件<br>a、命名格式<br>文件<em>语言</em>国家.properties<br>b、如果有非英文或数字转码<br>native2ascII -encoding utf-8 源 目标<br>2、在struts-config.xml中说明properties文件所在的位置</tiles:insert></p>
<p><message resource="struts.message"><br>3、在jsp中用标签通过键名取properties文件中的值</message></p>
<p><bean:message name="userName"><br>五、struts的手动校验:手动写代码实现校验规则。<br>1、国际化三步曲<br>2、校验通用两步曲<br>1、修改struts-config.xml中的action标签,加入<br>input及validate=”true”属性<br>2、在jsp页面中显示错误消息</bean:message></p>
<p><html:messages id="error"><br><br><brean:write name="error"><br></brean:write></html:messages><br>2、实现ActionForm<br>public class MyForm extends ActionForm<br>{<br>public ActionErrors validate()<br>{<br>ActionErrors ae=new ActionErrors();<br>ae.add(ActionErrors.glbal_message,new ActionMessage(“资源文件的键名”));<br>如果ae.size&gt;=1返回到input页面<br>如果ae.size&lt;1调用action的execute方法<br>}<br>}<br>六、struts的自动校验:通过xml文件配置具体的校验规则。<br>1、国际化三步曲<br>2、通用校验两步曲<br>3、实现ActionForm，继承于ValidateForm，不能覆盖validate方法<br>public class MyForm extends ActionForm<br>{<br>//public ActionErrors validate()<br>//<br>}<br>4、通过xml说明实现自动校验<br>1、拷入validation-rules.xml到/webrooe/WEB-INF目录下<br>2、复制validation-rules.xml得到的文件是validation.xml,修改结果如下</p>
<p><formset></formset></p>
<p><form name="loginForm"></form></p>
<p><field name="userName" depends="required"></field></p>
<p><arg0 key="userName"><br></arg0></p>
<p><field name="pwd" depends="required,minlength"></field></p>
<p><arg0 key="userName"></arg0></p>
<p><arg1 key="${var:minlength}" resource="false"><br><var><br><var-name>minlength</var-name><br><var-value>6</var-value><br></var><br><br></arg1></p>
<p><formset><br>当发生required错误时，在资源文件中对应的键名errors.required<br>errors.required={0} is not Empty<br>当发生minlength错误时，在资源文件中对应的键名errors.minlength<br>errors.minlength={0} ‘s minlength must be {1}<br>3、通过struts-config.xml的插件加入两个校验文件。<br>七、struts的tiles<br>作用:主页面加载从页面，具体的从页面不是在主页面中确定，而是<br>在tiles-defs.xml中定义，这样如果主页面的结构发生了改变，<br>只需的修改tiles-defs.xml文件，不用修改主页面本身。<br>实现思路:<br>1、在tiles-defs.xml中说明主页面、从页面的名称及uri。<br>2、action的execute方法执行结束时转发到tiles-defs中的一个<br>tiles, 通过该tiles找到主页面，主页面根据tiles中定<br>义的具体页面名称加载对应的jsp页面。<br>实现:<br>1、在tiles-defs.xml中说明主页面及其需要的从页面，具体如下:</formset></p>
<p><definition name="index" path="/index.jsp"></definition></p>
<p><put name="head" value="/head.jsp"></put></p>
<p><put name="body" value="/body.jsp"></put></p>
<p><put name="foot" value="/foot.jsp"><br><br>2、实现action，其forward指定不再是jsp页面，而是一个tiles<br>记住不能加”/“，直接给名称<br>3、在主页中通过名称找到具体的从页面</put></p>
<tiles:insert attribute="head">

<p>十七、struts的MVC<br>m:model<br>facade<br>dao<br>hibernate<br>v:<br>jsp<br>ActionForm<br>c:<br>ActionServlet:接收所有的请求进行处理<br>ActionMapping:是一个具体的action标签,<br>通过url找到action及actionForm<br>可以通过名称找到ActionForward转发到下一个页面。</p>
<p><action path="/login" type="struts.action.LoginAction" name="userForm" attribute="userForm" scope="request" validate="true" input="/login.jsp"></action></p>
<p><actionforward name="success" path="/success.jsp"><br><br>Action:做具体的业务处理<br>ActionForward:转发到另一个页面。<br>十八、struts的请求处理过程:<br>通过url.do在struts-config.xml中找到对应的action及ActionForm<br>如果有actionForm用已有没有产生一个新的，并通过反射将表单域<br>的值注入到actionForm实例中。<br>如果有action用已有的没有产生一个新的，调用action的execute方法，<br>在调用execute方法之前通过参数将ActionForm注入到execute方法，<br>execute 在执行结束前通过ActionMapping找到一个ActionForward转发<br>到下一个页面。</actionforward></p>
</tiles:insert></tiles:insert>
      
    </div>
    <footer class="article-footer">
      <a data-url="http://mhuihui.oschina.io/m-pages/m-pages/2017/01/11/Struts总结/" data-id="ciyzazas1000is8vgoq90amo8" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/m-pages/tags/编程/">编程</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-JAVA集合工具类详解" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/m-pages/2017/01/11/JAVA集合工具类详解/" class="article-date">
  <time datetime="2017-01-11T04:13:38.000Z" itemprop="datePublished">2017-01-11</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/m-pages/2017/01/11/JAVA集合工具类详解/">JAVA集合工具类详解</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<h2 id="集合的作用"><a href="#集合的作用" class="headerlink" title="集合的作用?"></a>集合的作用?</h2><blockquote>
<p>是数据的容器，可以存放不同类型的对象，集合有很多实现类,<br>作用是一样的，只不过存储的数据结构不一样，在增、删、改<br>查操作的效率上不一样。<br>集合的组成?</p>
<ul>
<li>接口<br>Colection List Set Map</li>
<li>实现类<br>ArrayList Vector LinkedList<br>HashSet TreeSet HashMap Hashtable</li>
<li>算法<br>Collections<br>1、sort:对一个集合排序<br>2、reverse:返序一个集合<br>3、max:取集合中最大值<br>4、min:</li>
<li>集合的框架结构?<br>Collection(可以直接加入一个对象，不用键名)<br>List(值可以重复) Set(值不可重复)<br>ArrayList Vector LinkedList HashSet TreeSet(可以排序，所以类型必须相同)<br>Map(键名+键值,键名不可以重复，键值可以重复)<br>HashMap Hashtable</li>
<li>集合的通用方法?<br>iterator<br>size<br>add<br>addAll:一个集合中加入另一个集合<br>remove:删除一个元素<br>removeAll:一个集合与中一个集合中的元素比较,若相同将当前集合删除<br>empty():是否为空<br>get(下标):取<br>indexOf(对象):查<br>List遍历的三种方式:</li>
<li>iterator</li>
<li>enumeration</li>
<li>Enumeration e=Collection.enumeration(集合);</li>
</ul>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">while(e.hasMoreElement())</div><div class="line">&#123;</div><div class="line">e.nextElement();</div><div class="line">&#125;</div><div class="line">for</div></pre></td></tr></table></figure>
<p>Set只有三种遍历方式:<br>iterator:迭代器<br>enumeration:序列<br>Hashmap或Hasttabel的相关方法<br>–得到所有键名<br>Set keys=hm.keySet();<br>–得到所有键值<br>Collection col=hm.values();<br>–得到所有键名+键值<br>Set set=hm.entrySet();</p>
<ul>
<li>三、队列:先进先出，从尾部进，从头出</li>
<li><p>四、栈:先进后出,从头部进，从头部出</p>
</li>
<li><p>二、队列线性表的实现</p>
<ul>
<li>1、先进先出，通过尾部进，通过头部出</li>
</ul>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div></pre></td><td class="code"><pre><div class="line">public class ListQuery</div><div class="line">&#123;</div><div class="line">private int maxSize;</div><div class="line">private int size;</div><div class="line">private int a[];</div><div class="line">private int vear=-1;</div><div class="line">private int front=0;</div><div class="line">public ListQuery(int maxSize)</div><div class="line">&#123;</div><div class="line">this.maxSize=maxSize;</div><div class="line">a=new int[maxSize];</div><div class="line">this.size=0;</div><div class="line">&#125;</div><div class="line">public void add(int i)</div><div class="line">&#123;</div><div class="line">if(this.isFull)</div><div class="line">&#123;</div><div class="line">System.out.println(&quot;队已满&quot;);</div><div class="line">return;</div><div class="line">&#125;</div><div class="line">this.a[++vear]=i;</div><div class="line">if(vear==maxSize-1)</div><div class="line">&#123;</div><div class="line">vear=-1;</div><div class="line">&#125;</div><div class="line">this.size++;</div><div class="line">&#125;</div><div class="line">public int remove()</div><div class="line">&#123;</div><div class="line">if(this.isEmpty)</div><div class="line">&#123;</div><div class="line">System.out.println(&quot;队已空&quot;);</div><div class="line">return;</div><div class="line">&#125;</div><div class="line">int temp=a[front++];</div><div class="line">if(front==maxSize)</div><div class="line">&#123;</div><div class="line">front=0;</div><div class="line">&#125;</div><div class="line">&#125;</div><div class="line">public boolean isEmpty()</div><div class="line">&#123;</div><div class="line">return size==0;</div><div class="line">&#125;</div><div class="line">public boolean isFull()</div><div class="line">&#123;</div><div class="line">return this.size==maxSize;</div><div class="line">&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>三、队列链表的实现<br>public class Node<br>{<br>public int data;<br>public Node next;<br>public Node(int data)<br>{<br>this.data=data;<br>}<br>}<br>public class LinkQuery<br>{<br>private Node front=null;<br>private Node vear=null;<br>public void add(int i)<br>{<br>Node newNode=new Node(i);<br>if(front==null &amp;&amp; vear=null)<br>{<br>front=newNode;<br>vear=newNode;<br>}<br>else<br>{<br>vear.next=newNode;<br>vear=newNode;<br>}<br>}<br>public void remove()<br>{<br>if(front==null)<br>{<br>System.out.println(“栈已空”);<br>return;<br>}<br>Node temp=front;<br>front=front.next();<br>if(front==null)<br>{<br>vear=null;<br>}<br>}<br>public boolean isEmpty()<br>{<br>return front==null;<br>}<br>}<br>四、栈,先进后出,只有一个出口，操作在头部进行<br>五、线性表<br>1、排序(从小到大)<br>1、选择法:第一个数与其余的所有数比较，将最小的数放到第一位，<br>第一位不再参与比较。<br>第二个数与其余的所有数比较，将次小的数放到第二位，<br>第二位不再参与比较。<br>for(int i=0;i<a.length()-1;i++) {="" int="" k="i;" for(int="" j="i+1;j<a.length();j++)" if(a[k]="">a[j])<br>{<br>k=j;<br>}<br>}<br>if(k!=i)<br>{<br>int temp=a[k];<br>a[k]=a[i];<br>a[i]=temp<br>}<br>}<br>2、冒泡法排序:<br>相邻的两个数进行比较，将最大的数放到最后面，最后的这个数不再参与比较<br>相邻的两个数进行比较，将次大的数放到次后面，次后的这个数不再参与比较<br>for(int i=0;i<a.length-1;i++) {="" for(int="" j="0;j<a.length-i-1;j++)" if(a[j]="">a[j+1])<br>{<br>swap(j,j+1);<br>}<br>}<br>}<br>3、插入法排序:假设第一数已排好序，如果第二数比第一数小，第一个数右移,第一位放第二个数。<br>int b[]={1000,-100,-99999,10,20,1,100,200,18};<br>for(int i=1;i<a.length;i++) {="" int="" temp="a[i];" sort="i;" while(i="">0 &amp;&amp; temp&lt;a[sort-1])<br>{<br>a[sort]=a[sort-1];<br>sort–;<br>}<br>a[sort]=temp;<br>}</a.length;i++)></a.length-1;i++)></a.length()-1;i++)></p>
<p>一、栈：先进后出，进与出都在头部操作<br>1、线性表的实现<br>public class ListStack<br>{<br>private int maxSize;<br>private int size;<br>private int top;<br>private int a[];<br>public ListStack(int maxSize)<br>{<br>this.maxSize=maxSize;<br>this.size=0;<br>top=-1;<br>a=new int[maxSize];<br>}<br>public void add(int i)<br>{<br>if(this.isFull)<br>{<br>System.out.println(“栈已满”);<br>return;<br>}<br>a[++top]=i;<br>size++;<br>}<br>public int remove()<br>{<br>if(this.isEmpty())<br>{<br>System.out.println(“栈已空”);<br>return -1;<br>}<br>temp=a[top–];<br>size–;<br>return temp;<br>}<br>public boolean isFull()<br>{<br>return this.size==this.maxSize;<br>}<br>public boolean isEmpty()<br>{<br>return this.size==0;<br>}<br>}<br>2、链表的实现<br>public class Node<br>{<br>public int data;<br>public Node next;<br>public Node(int data)<br>{<br>this.data=data;<br>}<br>}<br>public class LinkStack<br>{<br>private Node top;<br>public void push(int i)<br>{<br>Node newNode=new Node(i);<br>if(top==null)<br>{<br>top=newNode;<br>}<br>else<br>{<br>newNode.next=top;<br>top=newNode;<br>}<br>}<br>public int pop()<br>{<br>if(top==null)<br>{<br>System.out.println(“栈已空”);<br>return -1;<br>}<br>int temp=top.data;<br>top=top.nextNode;<br>retutn temp;<br>}<br>public boolean isEmpty()<br>{<br>return top==null;<br>}<br>}<br>二、线性表<br>public class List<br>{<br>int size;//实际元素的个数<br>int maxSize;//最大容量<br>int a[];//承载数据<br>int index;//当前最大的下标值<br>public List(int maxSize)<br>{<br>this.maxSize=maxSize;<br>a=new int[this.maxSize];<br>index=-1;<br>size=0;<br>}<br>public void addLast(int data)<br>{<br>if(this.isFull)<br>{<br>System.out.println(“线性表已满”);<br>return;<br>}<br>this.a[++index]=data;<br>this.size++;<br>}<br>public void print()<br>{<br>for(int i=0;i<size;i++) {="" system.out.println(a[i]);="" }="" *="" 选择法排序:="" 第一个数与剩余的所有数比较，将最小的数放到第一位，第一位不再参与参与比较="" 第二个数与剩余的所有数比较，将次小的数放到第二位，第二位不再参与参与比较="" public="" void="" selectsort()="" for(int="" i="0;i<this.size-1;i++)" int="" k="i;" j="i+1;j<this.size;j++)" if(a[k]="">a[j])<br>{<br>k=j;<br>}<br>}<br>if(k!=i)<br>{<br>int temp=a[k];<br>a[k]=a[i];<br>a[i]=temp;<br>}<br>}<br>}<br>/<em><br>冒泡法:<br>相邻数比较，将最大数放到最后，最后的这个数不再参与比较<br>相邻数比较，将次大数放到最后，次后的这个数不再参与比较
</em>/<br>public void maopaoSort()<br>{<br>for(int i=0;i<this.size-1;i++) {="" boolean="" flag="false;" for(int="" j="0;j<this.size-i-1;j++)" if(a[j]="">a[j+1])<br>{<br>int temp=a[j];<br>a[j]=a[j+1];<br>a[j+1]=temp;<br>flag=true;<br>}<br>}<br>if(flag==flase)<br>{<br>break;<br>}<br>}<br>}<br>/<em><br>插入法:假设第一数已排好序,<br>插入第二数时，第一数与第二个数比较，若第二个数小于第一数,第一数右移,<br>第一个位置放第二个数
</em>/<br>public void insertSort()<br>{<br>for(int i=1;i<this.size;i++) {="" int="" temp="a[i];" sort="i;" while(sort="">0 &amp;&amp; a[sort-1]&gt;temp)<br>{<br>a[sort]=a[sort-1];<br>sort–;<br>}<br>a[sort]=temp;<br>}<br>}<br>public boolean isEmpty()<br>{<br>return this.size==0;<br>}<br>public boolean isFull()<br>{<br>return this.size=this.maxSize;<br>}<br>}</this.size;i++)></this.size-1;i++)></size;i++)></p>
<p>一、线性表<br>public class List<br>{<br>private int maxSize;<br>private int size;<br>private int index;<br>private int a[];<br>public List(int maxSize)<br>{<br>this.maxSize=maxSize;<br>this.size=0;<br>this.index=-1;<br>a=new int[maxSize];<br>}<br>public void addLast(int data)<br>{<br>//如果满直接退出<br>this.a[++index]=data;<br>this.size++;<br>}<br>public void addFirst(int data)<br>{<br>//如果满直接退出<br>for(int j=index;j&gt;=0;j–)<br>{<br>a[j+1]=a[j];<br>}<br>a[0]=data;<br>this.index++;<br>this.size++;<br>}<br>public void addBefore(int oldData,int newData)<br>{<br>int pos=this.find(oldData);<br>if(pos!=-1)<br>{<br>for(int j=index;j&gt;=pos;j–)<br>{<br>a[j+1]=a[j];<br>}<br>a[pos]=newData;<br>this.index++;<br>this.size++;<br>}<br>}<br>public int find(int data)<br>{<br>for(int i=0;i<size;i++) {="" if(data="=a[i])" return="" i;="" }="" -1;="" public="" int="" removelast()="" 如果为空退出="" temp="a[index];" index--;="" size--;="" temp;="" removefirst()="" for(int="" i="0;i<index;i++)" a[i]="a[i+1];" this.index--;="" this.size--;="" remove(int="" deletedata)="" pos="this.find(deleteData);" if(pos="">=0)<br>{<br>for(int i=pos;i<index;i++) {="" a[i]="a[i+1];" }="" size--;="" index--;="" *="" 折半查找="" 1、是在已排好序的数组中处理="" 2、有三个变量="" lower:初始是0="" upper:初始是数据最大的下标="" mid="(lower+upper)/2;" 3、退出条件="" lower="">upper<br>4、逻辑处理<br>if(a[mid]==findData)<br>{<br>return mid;<br>}<br>else if(a[mid]&gt;findData)<br>{<br>upper=mid-1;<br>}<br>else<br>{<br>lower=mid+1;<br>}<br>*/<br>public void halfFind()<br>{<br>int lower=0;<br>int upper=index;<br>while(lower&lt;=upper)<br>{<br>int mid=(lower+upper)/2;<br>if(a[mid]==findData)<br>{<br>return mid;<br>}<br>else if(a[mid&gt;findData])<br>{<br>upper=mid-1;<br>}<br>else<br>{<br>lower=mid+1;<br>}<br>}<br>}<br>public boolean isEmpty()<br>{<br>return this.size==0;<br>}<br>public boolean isFull()<br>{<br>return this.size==this.maxSize;<br>}<br>}</index;i++)></size;i++)></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://mhuihui.oschina.io/m-pages/m-pages/2017/01/11/JAVA集合工具类详解/" data-id="ciyzazar70000s8vg93a8fmtu" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/m-pages/tags/编程/">编程</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-Linux安装多个JDK" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/m-pages/2017/01/11/Linux安装多个JDK/" class="article-date">
  <time datetime="2017-01-11T04:11:38.000Z" itemprop="datePublished">2017-01-11</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/m-pages/2017/01/11/Linux安装多个JDK/">Ubuntu将sun jdk替换默认的open jdk</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<h2 id="Ubuntu将sun-jdk替换默认的open-jdk"><a href="#Ubuntu将sun-jdk替换默认的open-jdk" class="headerlink" title="Ubuntu将sun jdk替换默认的open jdk"></a>Ubuntu将sun jdk替换默认的open jdk</h2><p>1.到官网下载安装包： jdk-7-linux-i586.tar.gz<br>2.创建安装目录：sudo mkdir /usr/lib/jvm</p>
<ol>
<li>解压缩：tar zxvf ./jdk-7-linux-i586.tar.gz -C /usr/lib/jvm<br>4.设置环境变量：vim ~/.bashrc<br>export JAVA_HOME=/usr/lib/jvm/jdk-7<br>export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib<br>export PATH=${JAVA_HOME}/bin:$PATH<br>关闭终端，重新打开<br>sudo update-alternatives –install /usr/bin/java java /usr/lib/jvm/jdk-7/bin/java 300<br>sudo update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/jdk-7/bin/javac 300<br>sudo update-alternatives –config java </li>
</ol>
<p>显示：</p>
<h2 id="选择-路径-优先级-状态"><a href="#选择-路径-优先级-状态" class="headerlink" title="  选择       路径                                    优先级  状态 "></a>  选择       路径                                    优先级  状态 </h2><ul>
<li>0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      自动模式<br>1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      手动模式<br>2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        手动模式 </li>
</ul>
<p>键入选择的编号：2<br>回车</p>
<p>4.验证下java -version发现已经改为sun的jre</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://mhuihui.oschina.io/m-pages/m-pages/2017/01/11/Linux安装多个JDK/" data-id="ciyzazarm0005s8vg52m27rte" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/m-pages/tags/linux/">linux</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-项目过程分析" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/m-pages/2017/01/10/项目过程分析/" class="article-date">
  <time datetime="2017-01-10T14:11:38.000Z" itemprop="datePublished">2017-01-10</time>
</a>
    
  </div>
  <div class="article-inner">
    
<div class="article-gallery">
  <div class="article-gallery-photos">
    
      <a class="article-gallery-img fancybox" href="https://static.hinpc.com/image/2016/201611-ipad-605420_1920.jpg!width600" rel="gallery_ciyzazat3001ds8vgngn45pnb">
        <img src="https://static.hinpc.com/image/2016/201611-ipad-605420_1920.jpg!width600" itemprop="image">
      </a>
    
  </div>
</div>

    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/m-pages/2017/01/10/项目过程分析/">项目过程分析</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<p>项目:<br>1、软件开发的过程:在面试时说明自己参与了某个项目的某个模块从需求到<br>设计到开发的所有过程。<br>1、需求分析(25-30%):一定客户签字认可，在合同要说明验收时以需求说明书的内容为准，<br>若有改动，需与商务另行商议。<br>成果：<br>需求说明书，具体内容如下:<br>demo(界面原型):需求的可视化<br>需求特征列表:简要的说明系统的功能，确定优先级及风险度<br>用例图:说明系统整体的功能<br>用例说明:<br>1、用流程图(活动图)说明<br>2、写用例说明文档，其有六大元素<br>功能描述<br>参与者<br>前置条件<br>后置条件<br>基本流<br>扩展流<br>2、整体设计(20-30%)<br>3、详细设计(10%可以不走这个过程)<br>4、编码(25-30%)<br>5、测试(10%)<br>2、ooa与ood的区别<br>3、面向方面与面向对象的区别<br>4、什么是模型<br>5、模型的作用<br>6、模型的原则<br>7、活动图:<br>主要用在需求分析阶段，说明某一个用例的业务流程。<br>元素如下:<br>开始<br>结束<br>状态<br>处理(动作)<br>判断<br>分支<br>汇集<br>泳道:说明不同角色所做的工作。</p>
<p>项目:<br>1、软件开发的过程:在面试时说明自己参与了某个项目的某个模块从需求到<br>设计到开发的所有过程。<br>1、需求分析(25-30%):一定客户签字认可，在合同要说明验收时以需求说明书的内容为准，<br>若有改动，需与商务另行商议。<br>成果：<br>需求说明书，具体内容如下:<br>demo(界面原型):需求的可视化<br>需求特征列表:简要的说明系统的功能，确定优先级及风险度<br>用例图:说明系统整体的功能<br>用例说明:<br>1、用流程图(活动图)说明<br>2、写用例说明文档，其有六大元素<br>功能描述<br>参与者<br>前置条件<br>后置条件<br>基本流<br>扩展流<br>2、整体设计(20-30%)<br>1、分析业务流程<br>bbs<br>登陆注册<br>浏览、发新帖、回复<br>短消息<br>用户管理<br>版块管理<br>帖子管理<br>2、根据业务设计业务实体<br>讨论区(1) 版块(0..n)<br>版块(1) 主帖(0..n)<br>主帖(1) 回帖(0..n)<br>用户(1) 帖子(主帖、回帖)(0..n)<br>用户(1) 消息(0..n)<br>3、确定项目的技术框架<br>框架设计的原则：上层依赖于下层，尽量减少下层对上层的<br>依赖，层与层之间通过接口调用。<br>轻量级的框架<br>jsp&amp;servlet&amp;dao&amp;jdbc:用的model2,速度是最快的，开发效率不高。<br>M:<br>facade&amp;dao&amp;jdbc<br>C:<br>serlvet<br>V:<br>jsp<br>通过jsp将请求发给servlet，servlet通过<br>FacadeFactory产生具体的Facade返回一个IFacade接口，通过IFacade接口<br>调用Facade的具体方法。<br>Facade通过dao的抽象工厂产生具体的工厂，通过具体的工厂产生具体的dao，<br>返回dao接口给业务层。<br>Facade执行完后将结果返回给servlet，servlet转发到下一个页面。<br>Servlet用了模板模式可以提供错误处理、事务、页面跳转的服务。<br>struts&amp;dao&amp;hibernate:速度较快，因为我们要自己实现工厂，但并不是所有的一切<br>都是返射，相对spring来说速度更快一些。<br>struts:<br>mvc，请求处理过程<br>用一个模块模式提供通用错误、事务、跳转服务。<br>将IFacade接口作业其属性，通过FacadeFactory工厂产生具体的Facade<br>返回一个Facade接口。<br>facade<br>IFacade接口<br>Facade实现类<br>FacadeFactory:facade工厂<br>dao接口作为Facade的属性，通过AbstractFactory调用具体的DaoFactory<br>产生具体的dao实例，返回dao接口。<br>dao:<br>dao<br>daoImpl<br>DaoFactory:产生daoImpl实例，返回dao接口<br>AbstractFactory:通过返射、工厂、单例产生具体的DaoFactory，返回<br>AbstractFactroy<br>hibernate<br>核心类<br>核配置文件<br>struts&amp;spring&amp;hibernate/ibatis：这是当前最通用、最快速、藕合度最低的开发方式<br>但也有一个问题spring一切都是返射，速度慢。<br>struts/hibenate/ibatis要解析xml文件、要大量用到返射，所以速度慢。<br>一般适合于中小型系统(500)，大型系统有些不适合需要调整。<br>struts已是MVC<br>spring是一个超级工厂，在spring中配置的都是实现类，在代码中得到都是接口。<br>hibenate/ibatis是o/r Mapping<br>框架结构:<br>struts:<br>mvc<br>请求处理过程<br>在spring中加入bean标签，配置具体的action,通过set方法将Facade代理<br>注入到action的IFcade接口中。<br>Facade<br>IFacade接口<br>Facade实现类<br>在applicationContext.xml配置具体的Facade类，在配置Facade的Aop服务时，<br>先配置抽象代理AbstractProxy其是TransactionProxyFactoryBean,说明装备<br>TransactionManager,说明连接点TransactionAttributes。再配置具体的<br>代理，继承于AbstractProxy，指向真实的对象。通过set方法注入将具体的<br>Dao注入到Facade的Dao接口属性中。<br>Dao<br>dao接口<br>dao的实现 extends HibernateDaoSupport/SqlMapClientSupport<br>在applicationContext.xml中配置具体的dao，向Facade返回dao接口。<br>hibernate<br>在applicationContext.xml中配置dataSource、sessionFactory,<br>通过set方法注入将sessionFactory注入到dao实现类中。<br>ibatis:<br>在applicationContext.xml中配置dataSource、sqlMapClient,<br>通过set方法注入将sqlMapClient注入到dao实现类中。<br>3、详细设计<br>对于开发能力比较强的团队，可以不做详细设计。<br>4、编码(25-30%)<br>5、测试(10%)<br>2、ooa与ood的区别<br>ooa:面向对象的分析，根据客户的业务找业务实体，与具体的技术无关，客户可以看懂。<br>ood:面向对象的设计，是ooa的全集，与具体的技术框架相结合进行设计。<br>3、面向过程与面向对象的区别<br>面向过程:<br>1、现实世界是对象，其在分析过程中是对象，<br>在设计过程不是对象而是方法与方法之间的调用,<br>容易与现实脱离，容易出错。<br>2、因为是方法与方法之间的调用，重用性不高，<br>无法达到宏观层次上的控制。<br>3、开发难、维护难、可扩展性差。<br>面向对象:<br>1、现实世界是对象，其在分析过程中是对象，<br>在设计过程还是对象<br>分析设计与现实接近，降低了开发的难度。<br>2、继承可以让概念在宏观层次重用，当层与层之间通过<br>接口或抽象类调用时，他们所依赖的不再是具体的实现<br>细节，而是宏观商业逻辑即接口、抽象类，具体的实现<br>是可以随时被替换的。<br>3、开方方便、好维护、好扩展<br>4、什么是模型<br>现实的浓缩。<br>5、模型的作用<br>1、便于分析、认识世界<br>2、便于存档、沟通<br>3、便于决策。<br>6、模型的原则<br>1、模型好坏决写系统的成败。<br>2、与现实越接近说明模型越正确。<br>3、模型不止一个，而是多个，它从不同的侧面说明现实的世界。<br>4、根据不同人的需求，模型有不同的实现细节。<br>7、活动图:<br>主要用在需求分析阶段，说明某一个用例的业务流程。<br>元素如下:<br>开始<br>结束<br>状态<br>处理(动作)<br>判断<br>分支<br>汇集<br>泳道:说明不同角色所做的工作。<br>8、类图<br>9、use-case图<br>10、时序图:在给定的时间内，对象与对象的之间交互<br>应用在详细设计阶段，通过类与类之间的交互<br>找类、找方法、验证系统的正确性。<br>元素:<br>横轴:<br>类与类之间的交互<br>纵轴:<br>时间</p>
<p>项目:<br>1、软件开发的过程:在面试时说明自己参与了某个项目的某个模块从需求到<br>设计到开发的所有过程。<br>1、需求分析(25-30%):一定客户签字认可，在合同要说明验收时以需求说明书的内容为准，<br>若有改动，需与商务另行商议。<br>成果：<br>需求说明书，具体内容如下:<br>demo(界面原型):需求的可视化<br>需求特征列表:简要的说明系统的功能，确定优先级及风险度<br>用例图:说明系统整体的功能<br>用例说明:<br>1、用流程图(活动图)说明<br>2、写用例说明文档，其有六大元素<br>功能描述<br>参与者<br>前置条件<br>后置条件<br>基本流<br>扩展流<br>2、整体设计(20-30%)<br>1、分析业务流程<br>bbs<br>登陆注册<br>浏览、发新帖、回复<br>短消息<br>用户管理<br>版块管理<br>帖子管理<br>2、根据业务设计业务实体<br>讨论区(1) 版块(0..n)<br>版块(1) 主帖(0..n)<br>主帖(1) 回帖(0..n)<br>用户(1) 帖子(主帖、回帖)(0..n)<br>用户(1) 消息(0..n)<br>3、确定项目的技术框架<br>框架设计的原则：上层依赖于下层，尽量减少下层对上层的<br>依赖，层与层之间通过接口调用。<br>轻量级的框架<br>jsp&amp;servlet&amp;dao&amp;jdbc:用的model2,速度是最快的，开发效率不高。<br>M:<br>facade&amp;dao&amp;jdbc<br>C:<br>serlvet<br>V:<br>jsp<br>通过jsp将请求发给servlet，servlet通过<br>FacadeFactory产生具体的Facade返回一个IFacade接口，通过IFacade接口<br>调用Facade的具体方法。<br>Facade通过dao的抽象工厂产生具体的工厂，通过具体的工厂产生具体的dao，<br>返回dao接口给业务层。<br>Facade执行完后将结果返回给servlet，servlet转发到下一个页面。<br>Servlet用了模板模式可以提供错误处理、事务、页面跳转的服务。<br>struts&amp;dao&amp;hibernate:速度较快，因为我们要自己实现工厂，但并不是所有的一切<br>都是返射，相对spring来说速度更快一些。<br>struts:<br>mvc，请求处理过程<br>用一个模块模式提供通用错误、事务、跳转服务。<br>将IFacade接口作业其属性，通过FacadeFactory工厂产生具体的Facade<br>返回一个Facade接口。<br>facade<br>IFacade接口<br>Facade实现类<br>FacadeFactory:facade工厂<br>dao接口作为Facade的属性，通过AbstractFactory调用具体的DaoFactory<br>产生具体的dao实例，返回dao接口。<br>dao:<br>dao<br>daoImpl<br>DaoFactory:产生daoImpl实例，返回dao接口<br>AbstractFactory:通过返射、工厂、单例产生具体的DaoFactory，返回<br>AbstractFactroy<br>hibernate<br>核心类<br>核配置文件<br>struts&amp;spring&amp;hibernate/ibatis：这是当前最通用、最快速、藕合度最低的开发方式<br>但也有一个问题spring一切都是返射，速度慢。<br>struts/hibenate/ibatis要解析xml文件、要大量用到返射，所以速度慢。<br>一般适合于中小型系统(500)，大型系统有些不适合需要调整。<br>struts已是MVC<br>spring是一个超级工厂，在spring中配置的都是实现类，在代码中得到都是接口。<br>hibenate/ibatis是o/r Mapping<br>框架结构:<br>struts:<br>mvc<br>请求处理过程<br>在spring中加入bean标签，配置具体的action,通过set方法将Facade代理<br>注入到action的IFcade接口中。<br>Facade<br>IFacade接口<br>Facade实现类<br>在applicationContext.xml配置具体的Facade类，在配置Facade的Aop服务时，<br>先配置抽象代理AbstractProxy其是TransactionProxyFactoryBean,说明装备<br>TransactionManager,说明连接点TransactionAttributes。再配置具体的<br>代理，继承于AbstractProxy，指向真实的对象。通过set方法注入将具体的<br>Dao注入到Facade的Dao接口属性中。<br>Dao<br>dao接口<br>dao的实现 extends HibernateDaoSupport/SqlMapClientSupport<br>在applicationContext.xml中配置具体的dao，向Facade返回dao接口。<br>hibernate<br>在applicationContext.xml中配置dataSource、sessionFactory,<br>通过set方法注入将sessionFactory注入到dao实现类中。<br>ibatis:<br>在applicationContext.xml中配置dataSource、sqlMapClient,<br>通过set方法注入将sqlMapClient注入到dao实现类中。<br>3、详细设计<br>对于开发能力比较强的团队，可以不做详细设计。<br>4、编码(25-30%)<br>5、测试(10%)<br>2、ooa与ood的区别<br>ooa:面向对象的分析，根据客户的业务找业务实体，与具体的技术无关，客户可以看懂。<br>ood:面向对象的设计，是ooa的全集，与具体的技术框架相结合进行设计。<br>3、面向过程与面向对象的区别<br>面向过程:<br>1、现实世界是对象，其在分析过程中是对象，<br>在设计过程不是对象而是方法与方法之间的调用,<br>容易与现实脱离，容易出错。<br>2、因为是方法与方法之间的调用，重用性不高，<br>无法达到宏观层次上的控制。<br>3、开发难、维护难、可扩展性差。<br>面向对象:<br>1、现实世界是对象，其在分析过程中是对象，<br>在设计过程还是对象<br>分析设计与现实接近，降低了开发的难度。<br>2、继承可以让概念在宏观层次重用，当层与层之间通过<br>接口或抽象类调用时，他们所依赖的不再是具体的实现<br>细节，而是宏观商业逻辑即接口、抽象类，具体的实现<br>是可以随时被替换的。<br>3、开方方便、好维护、好扩展<br>4、什么是模型<br>现实的浓缩。<br>5、模型的作用<br>1、便于分析、认识世界<br>2、便于存档、沟通<br>3、便于决策。<br>6、模型的原则<br>1、模型好坏决写系统的成败。<br>2、与现实越接近说明模型越正确。<br>3、模型不止一个，而是多个，它从不同的侧面说明现实的世界。<br>4、根据不同人的需求，模型有不同的实现细节。<br>7、活动图:<br>主要用在需求分析阶段，说明某一个用例的业务流程。<br>元素如下:<br>开始<br>结束<br>状态<br>处理(动作)<br>判断<br>分支<br>汇集<br>泳道:说明不同角色所做的工作<br>8、类图<br>9、use-case图<br>10、时序图:在给定的时间内，对象与对象的之间交互<br>应用在详细设计阶段，通过类与类之间的交互<br>找类、找方法、验证系统的正确性。<br>元素:<br>横轴:<br>类与类之间的交互<br>纵轴:<br>时间<br>11、协作图:对象与对象之间的交互，与时序图作用类似，但<br>没有进间的概念，通过序号说明先后顺序。<br>元素:<br>对象<br>交互<br>12、状态图:一个对象在不同方法的作用下状态的改变，<br>适合于面向过程开发。<br>13、构件图:说明组件与组件或层与层之间的依赖关系。<br>14、部署图:在分布式系统中说明各主机之间的关系，找出系统运行的<br>瓶颈。<br>元素:<br>节点:一个主机代表一个节点。</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://mhuihui.oschina.io/m-pages/m-pages/2017/01/10/项目过程分析/" data-id="ciyzazat3001ds8vgngn45pnb" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/m-pages/tags/编程/">编程</a></li></ul>

    </footer>
  </div>
  
</article>


  


  <nav id="page-nav">
    <span class="page-number current">1</span><a class="page-number" href="/m-pages/page/2/">2</a><a class="page-number" href="/m-pages/page/3/">3</a><a class="extend next" rel="next" href="/m-pages/page/2/">__('next') &raquo;</a>
  </nav>
</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/m-pages/tags/ide/">ide</a></li><li class="tag-list-item"><a class="tag-list-link" href="/m-pages/tags/linux/">linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/m-pages/tags/编程/">编程</a></li><li class="tag-list-item"><a class="tag-list-link" href="/m-pages/tags/设计/">设计</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/m-pages/tags/ide/" style="font-size: 13.33px;">ide</a> <a href="/m-pages/tags/linux/" style="font-size: 16.67px;">linux</a> <a href="/m-pages/tags/编程/" style="font-size: 20px;">编程</a> <a href="/m-pages/tags/设计/" style="font-size: 10px;">设计</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/m-pages/archives/2017/02/">February 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/m-pages/archives/2017/01/">January 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/m-pages/archives/2016/12/">December 2016</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/m-pages/2017/02/10/go语言学习笔记（四)/">go语言学习笔记（四）</a>
          </li>
        
          <li>
            <a href="/m-pages/2017/02/10/hello-world/">Hello World</a>
          </li>
        
          <li>
            <a href="/m-pages/2017/01/14/go语言学习笔记（三）/">go语言学习笔记（三）</a>
          </li>
        
          <li>
            <a href="/m-pages/2017/01/13/go语言学习笔记（二）/">go语言学习笔记（二）结构体和切片</a>
          </li>
        
          <li>
            <a href="/m-pages/2017/01/12/go语言学习笔记（一）/">go语言开发环境搭建</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2017 hui<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/m-pages/" class="mobile-nav-link">Home</a>
  
    <a href="/m-pages/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/m-pages/fancybox/jquery.fancybox.css">
  <script src="/m-pages/fancybox/jquery.fancybox.pack.js"></script>


<script src="/m-pages/js/script.js"></script>

  </div>
</body>
</html>